package com.wollo.controller;

import com.github.pagehelper.PageInfo;
import com.wollo.domain.AjaxResult;
import com.wollo.domain.PageResult;
import com.wollo.domain.TMenu;
import com.wollo.domain.User;
import com.wollo.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * //
 * //   █████▒█    ██  ▄████▄   ██ ▄█▀       ██████╗ ██╗   ██╗ ██████╗
 * // ▓██   ▒ ██  ▓██▒▒██▀ ▀█   ██▄█▒        ██╔══██╗██║   ██║██╔════╝
 * // ▒████ ░▓██  ▒██░▒▓█    ▄ ▓███▄░        ██████╔╝██║   ██║██║  ███╗
 * // ░▓█▒  ░▓▓█  ░██░▒▓▓▄ ▄██▒▓██ █▄        ██╔══██╗██║   ██║██║   ██║
 * // ░▒█░   ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄       ██████╔╝╚██████╔╝╚██████╔╝
 * //  ▒ ░   ░▒▓▒ ▒ ▒ ░ ░▒ ▒  ░▒ ▒▒ ▓▒       ╚═════╝  ╚═════╝  ╚═════╝
 * //  ░     ░░▒░ ░ ░   ░  ▒   ░ ░▒ ▒░
 * //  ░ ░    ░░░ ░ ░ ░        ░ ░░ ░
 * //           ░     ░ ░      ░  ░
 * //                 ░
 *
 * @author Java song
 * @date 2024/9/18 下午4:31
 * @description 菜单控制类
 **/
@Controller
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;
    //TODO 跳转菜单管理首页

    @RequestMapping("/list")
    @ResponseBody
    public AjaxResult menuList(HttpSession session) {
        User user = (User) session.getAttribute("user");
        List<TMenu> menus = menuService.selectBy(null,"sjq");
        return AjaxResult.ok(menus);
    }

    @RequestMapping("/mypage")
    public String mypage(){
        return "menu";
    }
    @RequestMapping("/listAll")
    @ResponseBody
    public PageResult menuListAll(Integer page, Integer limit) {
        PageResult<TMenu> tMenuPageResult = menuService.selectAll(page, limit);
        return tMenuPageResult;
    }

}
